package com.yq.cp.controller.data;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yq.cp.entity.basics.EquipmentManagement;
import com.yq.cp.entity.basics.OrganizationalStructure;
import com.yq.cp.entity.common.ApiResult;
import com.yq.cp.entity.common.PageVo;
import com.yq.cp.entity.data.NengKongDataDay;
import com.yq.cp.entity.data.dto.NyzfdqkDto;
import com.yq.cp.entity.data.vo.IndexGfVo;
import com.yq.cp.entity.manage.OpsTicketsMessage;
import com.yq.cp.service.basics.OrganizationalStructureService;
import com.yq.cp.service.data.IndexGfService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 大数据接口
 * </p>
 *
 * @author shen
 * @since 2023-06-10
 */

@RestController
@RequestMapping("/index/gf")
public class IndexGfController {

    @Resource
    private IndexGfService indexGfService;
    @Resource
    OrganizationalStructureService organizationalStructureService;


    @PostMapping("/query1")
    public ApiResult query1(@RequestBody NengKongDataDay n){
        Map<String, Object> map = indexGfService.query1(n);
        return ApiResult.success(map);
    }

    @PostMapping("/query11")
    public ApiResult query11(@RequestBody NengKongDataDay n){
        Map<String, Object> map = indexGfService.query11(n);
        return ApiResult.success(map);
    }
    @PostMapping("/query2")
    public ApiResult query2(@RequestBody IndexGfVo v){
//        v.setType(101);
//        Map<String, Object> map = indexGfService.query2(v);
        Map<String, Object> map =new HashMap<>();
        v.setType(112);
        Map<String, Object> m1 = indexGfService.query251(v);
        v.setType(113);
        Map<String, Object> m3 = indexGfService.query253(v);
        v.setType(114);
        Map<String, Object> m2 = indexGfService.query252(v);
        v.setType(118);
        Map<String, Object> m5 = indexGfService.query255(v);
        map.put("list1",m1.get("list1"));
        map.put("list2",m1.get("list2"));
        map.put("list3",m2.get("list2"));
        map.put("list4",m3.get("list2"));
        map.put("list5",m5.get("list2"));
        return ApiResult.success(map);
    }
    @PostMapping("/query3")
    public ApiResult query3(@RequestBody IndexGfVo v){
        v.setType(107);
        Map<String, Object> map = indexGfService.query3(v);
        return ApiResult.success(map);
    }

    @PostMapping("/query4")
    public ApiResult query4(){
        List<NyzfdqkDto> list = indexGfService.query4();
        return ApiResult.success(list);
    }

    @PostMapping("/query5")
    public ApiResult query5(){
        List<NyzfdqkDto> list = indexGfService.query5();
        return ApiResult.success(list);
    }
    /**
     * 发电量
     * */
    @PostMapping("/query6")
    public ApiResult query6(@RequestBody IndexGfVo v){
        v.setEnergyId(v.getId());
        // 112-上网  113-消网  114-下网
//        Map<String, Object> map=new HashMap<>();
//        v.setType(112);
//        Map<String, Object> m1 = indexGfService.query6(v);
//        v.setType(113);
//        Map<String, Object> m2 = indexGfService.query6(v);
//        v.setType(114);
//        Map<String, Object> m3= indexGfService.query6(v);
//        map.put("m1",m1);
//        map.put("m2",m2);
//        map.put("m3",m3);

//        v.setType(101);
//        Map<String, Object> m0 = indexGfService.query2(v);
//        map.put("m2",m0);
        Map<String, Object> map=new HashMap<>();
        v.setType(112);
        Map<String, Object> m1 = indexGfService.query251(v);
        v.setType(113);
        Map<String, Object> m2 = indexGfService.query253(v);
        v.setType(114);
        Map<String, Object> m3 = indexGfService.query252(v);
        v.setType(118);
        Map<String, Object> m5 = indexGfService.query255(v);
        map.put("m1",m5);
        map.put("m2",m2);
        map.put("m3",m3);
        return ApiResult.success(map);
    }

    /**
     * 发电量
     * */
    @PostMapping("/query611")
    public ApiResult query611(@RequestBody IndexGfVo v){
        v.setEnergyId(v.getId());
        Map<String, Object> map=new HashMap<>();
        if (v.getTypeNumber()==1){
            v.setType(107);
            Map<String, Object> m1 = indexGfService.query32(v);
            map.put("m1",m1);
            map.put("m6",new ArrayList<>());
        }else {
            v.setType(118);
            Map<String, Object> m1 = indexGfService.query254(v);
            v.setType(118);
            Map<String, Object> m6 = indexGfService.query256(v);
            map.put("m1",m1);
            map.put("m6",m6);
        }
        BigDecimal mfxss = organizationalStructureService.mfxss(v.getEnergyId());
        map.put("mfxss",mfxss);
        v.setType(v.getTypeNumber());
        Map<String, Object> cxlj = indexGfService.cxlj(v);
        map.put("m",cxlj);
        return ApiResult.success(map);
    }
    /**
     * 发电功率  / 辐射强度
     * */
    @PostMapping("/query7")
    public ApiResult query7(@RequestBody IndexGfVo v){
        Map<String, Object> map=new HashMap<>();
        v.setType(107);
//        Map<String, Object> m1 = indexGfService.query3(v);
        Map<String, Object> m1 = indexGfService.query32(v);
        v.setType(108);
//        Map<String, Object> m2 = indexGfService.query3(v);
        Map<String, Object> m2 = indexGfService.query32(v);
        map.put("m1",m1);
        map.put("m2",m2);
        return ApiResult.success(map);
    }

    /**
     * 发电数据
     * */
    @PostMapping("/nyzQuery1")
    public ApiResult nyzQuery1(@RequestBody NengKongDataDay n){
        Map<String, Object> m1 = indexGfService.nyzQuery1(n);
        return ApiResult.success(m1);
    }
    /**
     * 设计稿中心数据数据
     * */
    @PostMapping("/nyzQuery2")
    public ApiResult nyzQuery2(@RequestBody NengKongDataDay n){
        Map<String, Object> m1 = indexGfService.nyzQuery2(n);
        return ApiResult.success(m1);
    }
    /**
     * 设备列表
     * */
    @PostMapping("/nyzQuery3")
    public ApiResult nyzQuery3(@RequestBody NengKongDataDay n){
        List<Map<String,Object>> m1 = indexGfService.nyzQuery3(n);
        return ApiResult.success().data(m1);
    }
    @PostMapping("/nyzQuery4")
    public ApiResult nyzQuery4(@RequestBody NengKongDataDay n){
        Map<String, Object> map = indexGfService.nyzQuery4(n);
        return ApiResult.success().data(map);
    }

    /**
     * 查询工单
     * */
    @PostMapping("/gd")
    public ApiResult list(@RequestBody PageVo val){
        Page<OpsTicketsMessage> page = indexGfService.gd(val);
        return ApiResult.success(page);
    }

    /**
     * 查询位置
     * */
    @PostMapping("/wzxx")
    public ApiResult wzxx(){
        List<OrganizationalStructure> wzxx = indexGfService.wzxx();
        return ApiResult.success(wzxx);
    }

    /**
     * 监控地址
     * */
    @PostMapping("/jkdz")
    public ApiResult jkdz(@RequestBody PageVo val){
        List<EquipmentManagement> objects = indexGfService.jkdz1(val.getId());
        return ApiResult.success(objects);
    }

    @PostMapping("/nyzQueryXcx")
    public ApiResult nyzQueryXcx(@RequestBody NengKongDataDay val){
        Map<String, Object> map = indexGfService.nyzQueryXcx(val);
        return ApiResult.success(map);
    }

    @PostMapping("/nyzQueryXcx11")
    public ApiResult nyzQueryXcx11(@RequestBody NengKongDataDay val){
        Map<String, Object> map = indexGfService.nyzQueryXcx11(val);
        return ApiResult.success(map);
    }
}
